<?php
/*
 * Glorious CMS
 * Written by Andrew Mikhaylov
 * (c) 2010
 */

class Config extends Singleton
{
    protected $items = array();

    public function instance() {
        return parent::instance(__CLASS__);
    }

    protected function __construct()
    {
    }

    public function load($config_name) {
        
        $config = &$this->items;

        $filename = fetch_file(array(APPPATH . 'config/', BASEPATH . 'config/'), array($config_name, strtolower($config_name)));

        if($filename !== false)
            include($filename);

    }

    public function item($item, $subitem = false, $default = false) {

        if($subitem === false) {
            if(isset($this->items[$item]))
                return $this->items[$item];
        } else {
            if(isset($this->items[$item]) &&
               isset($this->items[$item][$subitem]))
                 return $this->items[$item][$subitem];
        }

        return $default;
    }

    public function set_item($item, $value) {

        if(isset($this->items[$item])) {
            $this->items[$item] = $value;
            return true;
        }

        return false;
    }

}



/* End of file config.php */
/* Location ./system/libraries/config.php */